package com.ruoyi.project.drug.service.impl;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.project.drug.domain.Factories;
import com.ruoyi.project.drug.mapper.FactoriesMapper;
import com.ruoyi.project.drug.service.IFactoriesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class FactoriesServiceImpl implements IFactoriesService {
    @Autowired
    private FactoriesMapper factoriesMapper;
    @Override
    public List<Factories> getFactories(Factories factories) {
        return factoriesMapper.selectFactories(factories);
    }

    @Override
    public int insertFactories(Factories factories) {
        //实体类继承父类BaseEntity,可以直接调用父类的创建时间方法
        factories.setCreateTime(new Date());
        return factoriesMapper.newFactories(factories);
    }
    /**根据生产厂ID获取生产厂信息*/
    @Override
    public Factories getById(Long facId) {
        return factoriesMapper.selectById(facId);
    }

    /**修改生产厂信息*/
    @Override
    public int updateFactories(Factories factories) {
        factories.setUpdateTime(new Date());
        return factoriesMapper.alterFactories(factories);
    }

    @Override
    public int deleteFactories(Long[] facIds) {
        return factoriesMapper.dropFactories(facIds);
    }

    @Override
    public List<Factories> allFactories() {
        return factoriesMapper.allOfFac();
    }
}
